function doSubmit() {
    var username = $("#username").val();
    var password = $("#password").val();
    if (!username || username === "") {
        showMsg("请输入用户名");
        $("#form").username.focus();
        return false;
    }
    if (!password || password === "") {
        showMsg("请输入密码");
        $("#form").password.focus();
        return false;
    }
    console.log(window.location.host);
    //获取用户信息并进行验证
    $.ajax({
        url: "/login",
        data: JSON.stringify({"username": username, "password": password}),
        type: "POST",
        contentType: "application/json",
        success: function (data) {
            if (data) {
                if (data.code === 0) {
                    setTimeout(function () {
                        showMsg("正在登录中...");
                        console.log(data);
                        document.cookie = "sample_token" + "=" + data.data;
                        window.location.href = "/view/index";//指向登录的页面地址
                    }, 100)
                } else {
                    //显示登录失败的原因
                    showMsg(data.message);
                    return false;
                }
            }
        },
        error: function (data) {
            showMsg(data.message);
        }
    });
}

//错误信息提醒
function showMsg(msg) {
    $("#CheckMsg").text(msg);
}